// jest.config.js
// module.exports = {
//     moduleFileExtensions: [
//         'js',
//         'ts',
//         'json',
//         'vue'
//     ],
//     transform: {
//         '^.+\\.ts$': 'ts-jest',
//         '^.+\\.vue$': 'vue-jest'
//     }
// }

// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

module.exports = {
  rootDir: path.resolve(__dirname),
  clearMocks: true,
  coverageDirectory: "coverage",
  coverageProvider: "v8",
  moduleFileExtensions: ["vue", "js", "json", "jsx", "ts", "tsx", "node"],
  // 别名设置
  moduleNameMapper: {
    "@/(.*)$": "<rootDir>/src/$1"
  },
  preset: "ts-jest",
  testEnvironment: "jsdom",
  // 测试文件
  testMatch: ["<rootDir>__test__/**/*.spec.(ts|tsx|js)"],
  // testPathIgnorePatterns: ["/node_modules/"],
  testPathIgnorePatterns: ["<rootDir>/node_modules/(?!lodash-es)"],

  // eslint-disable-next-line no-dupe-keys
  moduleFileExtensions: ["js", "json", "ts", "tsx"],

  transform: {
    "^.+\\.vue$": "vue-jest",
    "^.+\\.(ts|tsx|js|jsx)$": [
      "babel-jest",
      {
        presets: [
          ["@babel/preset-env", { targets: { node: "current" } }],
          ["@babel/preset-typescript"],
          "babel-preset-vite"
        ],
        plugins: ["@vue/babel-plugin-jsx"]
      }
    ]
  }
};
